fix(main): surface invalid-subcommand hint in agent --help - #735
Open
amaskara-dd wants to merge 1 commit into
Open
fix(main): surface invalid-subcommand hint in agent --help#735amaskara-dd wants to merge 1 commit into
amaskara-dd wants to merge 1 commit into
Conversation
amaskara-dd
force-pushed
the
fix/agent-help-invalid-subcommand
branch
2 times, most recently
from
August 26, 2026 16:53
21d7264 to
1f0e80a
Compare
amaskara-dd
marked this pull request as ready for review
August 26, 2026 16:58
platinummonkey
previously approved these changes
Aug 26, 2026
This comment has been minimized.
This comment has been minimized.
In agent mode, `--help` is intercepted before clap to emit a JSON schema. The intercept resolved the requested subcommand and fell through a catch-all to the generic root schema (exit 0) whenever it didn't resolve — swallowing clap's "did you mean" suggestion. So `pup monitor list --help --agent` was less helpful than the same command without `--help`. Only emit a schema when the request resolves to a real command (or no subcommand was given); for an unknown subcommand, fall through to clap so it reports the typo with a suggestion. - Make `find_subcommand` alias-aware so valid aliases (e.g. `audit`) still return the scoped JSON schema instead of clap text help. - Extract `top_level_subcommand` to skip values of value-taking global flags (`--org`, `-o/--output`, `--jq`), so `--org x monitors --help` scopes to `monitors`, not the flag value. - Add unit tests for subcommand resolution, alias handling, and top-level extraction. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
amaskara-dd
force-pushed
the
fix/agent-help-invalid-subcommand
branch
from
August 26, 2026 18:22
1f0e80a to
bddda4f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What does this PR do?
Use clap help text in agent mode for invalid subcommands
Motivation
Some experiments were showing that a lot of tokens are wasted in
--agentmode when the agent uses the wrong command name (i.epup monitorsvspup monitor). In such cases, the clap output is far more useful than the root level agent schemaAdditional Notes
Checklist
Related Issues